//
//  LCSigninVC.swift
//  Litchi
//
//  Created by Azzan on 2018/4/12.
//  Copyright © 2018年 Azzan. All rights reserved.
//

import UIKit

class LCSigninVC: UIViewController {

    @IBOutlet weak var codeBT: UIButton!
    @IBOutlet weak var phonetf: UITextField!
    @IBOutlet weak var codeTF: UITextField!
    @IBOutlet weak var passwordTF: UITextField!
    @IBOutlet weak var password2TF: UITextField!
    var timeCount = 0
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    @IBAction func getCode(_ sender: Any) {
        
    }
    @IBAction func register(_ sender: Any) {
        
        
    }
    
    func keepTime(){
        codeBT.titleLabel?.text = "60s"
        codeBT.isEnabled = false
        timeCount = 60
        codeBT.setTitleColor(#colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1), for: UIControlState.disabled)
        Timer.scheduledTimer(timeInterval: 1, target: self, selector:#selector(tickDown(_:)), userInfo: nil, repeats: true);
    }
    
    @objc func tickDown(_ timer:Timer?){
        if timeCount > 1{
            timeCount -= 1
            codeBT.setTitle("\(timeCount)s", for: UIControlState.disabled)
        }else{
            timer?.invalidate()
            codeBT.isEnabled = true
            codeBT.setTitle("获取验证码", for: UIControlState.normal)
        }
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
